<?php

namespace backend\models;

use Yii;

/**
 * This is the model class for table "generalocr".
 *
 * @property string $id
 * @property string $user_id
 * @property string $filename 文件名
 * @property string $title
 * @property string $path 文件路径
 * @property string $ocr_ret 主体包内容
 * @property string $ocr_string 字段字符串
 * @property string $created_at
 */
class Generalocr extends \yii\db\ActiveRecord
{
    /**
     * @inheritdoc
     */
    public static function tableName()
    {
        return 'generalocr';
    }

    /**
     * @inheritdoc
     */
    public function rules()
    {
        return [
            [['filename',], 'required'],
            [['ocr_ret', 'title'], 'string'],
            [['user_id', 'order'], 'integer'],
            [['filename', 'path'], 'string', 'max' => 255],
            [['created_at', 'ocr_ret', 'ocr_string', 'ocr_origin'], 'safe'],
        ];
    }

    /**
     * @inheritdoc
     */
    public function attributeLabels()
    {
        return [
            'id' => 'ID',
            'title' => '案卷名称',
            'filename' => '文件名',
            'path' => '文件路径',
            'ocr_ret' => '主体包内容',
            'ocr_string' => '字段字符串',
            'user_id' => '上传人',
            'created_at' => '上传时间',
            'order' => '序号',
        ];
    }

    /**
     * @inheritdoc
     * @return GeneralocrQuery the active query used by this AR class.
     */
    public static function find()
    {
        return new GeneralocrQuery(get_called_class());
    }

    public function getUploader()
    {
        return $this->hasOne(User::className(), ['id' => 'user_id']);
    }
}
